package it.asvp.asvp_portal.data.entity.event;


import it.asvp.asvp_portal.asvp_util.enumerative.EventType;
import it.asvp.asvp_portal.data.entity.domain.BaseEntity;
import it.asvp.asvp_portal.data.entity.member.Member;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

@SuppressWarnings("serial")
@Entity
@Table(name = "event", catalog = "asvp_db")
public class Event extends BaseEntity {
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	private Long id;
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "id_member", nullable = false)
	private Member member;
	
	@Column(name = "event_type", nullable = false, length = 50)
	@Enumerated(EnumType.STRING)
	private EventType eventType;
	
	@Column(name = "title", nullable = false, length = 100)
	private String title;
	
	@Column(name = "place", nullable = false, length = 200)
	private String place;
	
	@Column(name = "description", nullable = false, length = 1000)
	private String description;
	
	@Temporal(TemporalType.DATE)
	@Column(name = "start_date", length = 10)
	private Date startDate;
	
	@Temporal(TemporalType.DATE)
	@Column(name = "end_date", length = 10)
	private Date endDate;
	
	@Column(name = "priority", nullable = false)
	private boolean priority;
	
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "event")
	@Cascade({CascadeType.ALL})
	private Set<EventPicture> eventPictures = new HashSet<EventPicture>(0);

	public Event() {
	}

	public Event(Member member, EventType eventType, String title,
			String place, String description, Date startDate, Date endDate,
			boolean priority, Date createdOn, Date lastUpdate,
			Set<EventPicture> eventPictures) {
		this.member = member;
		this.eventType = eventType;
		this.title = title;
		this.place = place;
		this.description = description;
		this.startDate = startDate;
		this.endDate = endDate;
		this.priority = priority;
		this.createdOn = createdOn;
		this.lastUpdate = lastUpdate;
		this.eventPictures = eventPictures;
	}

	
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	
	public Member getMember() {
		return this.member;
	}

	public void setMember(Member member) {
		this.member = member;
	}

	public EventType getEventType() {
		return this.eventType;
	}

	public void setEventType(EventType eventType) {
		this.eventType = eventType;
	}

	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	
	public String getPlace() {
		return this.place;
	}

	public void setPlace(String place) {
		this.place = place;
	}

	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	
	public Date getStartDate() {
		return this.startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}


	public Date getEndDate() {
		return this.endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}


	public boolean isPriority() {
		return this.priority;
	}

	public void setPriority(boolean priority) {
		this.priority = priority;
	}


	public Set<EventPicture> getEventPictures() {
		return this.eventPictures;
	}

	public void setEventPictures(Set<EventPicture> eventPictures) {
		this.eventPictures = eventPictures;
	}

}
